package com.sinopec.basemodule.base.basekt

import android.view.View
import com.jakewharton.rxbinding3.view.clicks
import com.sinopec.basemodule.base.BaseFragment
import com.sinopec.basemodule.base.BasePresenter
import java.util.concurrent.TimeUnit

/**
 * kt 版本的base
 */
abstract class BaseFragmentKt<T : BasePresenter>(
    private val layoutId: Int,
) : BaseFragment<T>() {

    fun View.click(onClick: (View) -> Unit) {
        addDisposable(
            clicks()
                .throttleFirst(1, TimeUnit.SECONDS)
                .subscribe { onClick(this) }
        )
    }


    override fun getLayoutId(): Int {
        return layoutId
    }

}